// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) definits fieldsfirst ansi space safe 
// Source File Name:   Remote.java

package jones.behavior;

import jones.RemoteControlState;
import jones.SimpleRobotInterface;

// Referenced classes of package jones.behavior:
//            Behavior, Arbiter

public class Remote
    implements Behavior
{

    private static final String NAME = "Remote";
    private boolean isFirstTime = false;

    public Remote()
    {
        isFirstTime = true;
    }

    public String getName()
    {
        return "Remote";
    }

    public void update(double d)
    {
    }

    public void act(Arbiter arbiter)
    {
        SimpleRobotInterface robot = (SimpleRobotInterface)arbiter.getRobotInterface(((Behavior) (this)));
        RemoteControlState state = robot.getRemoteControlState();
        if (state == RemoteControlState.FORWARD)
        {
            robot.setLeftWheelSpeed(255);
            robot.setRightWheelSpeed(255);
            isFirstTime = true;
        } else
        if (state == RemoteControlState.LEFT)
        {
            robot.setLeftWheelSpeed(-255);
            robot.setRightWheelSpeed(255);
            isFirstTime = true;
        } else
        if (state == RemoteControlState.RIGHT)
        {
            robot.setRightWheelSpeed(-255);
            robot.setLeftWheelSpeed(255);
            isFirstTime = true;
        } else
        if (state == RemoteControlState.BACKWARD)
        {
            robot.setLeftWheelSpeed(-255);
            robot.setRightWheelSpeed(-255);
            isFirstTime = true;
        } else
        if (state == RemoteControlState.NONE && isFirstTime)
        {
            robot.setLeftWheelSpeed(0);
            robot.setRightWheelSpeed(0);
            isFirstTime = false;
        }
    }

    public String toString()
    {
        return "Remote";
    }
}
